package com.hualan.zhsq.service.impl.information;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hualan.zhsq.entity.information.StorageRoom;
import com.hualan.zhsq.mapper.information.StorageRoomMapper;
import com.hualan.zhsq.service.information.StorageRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class StorageRoomServiceImpl implements StorageRoomService {

    @Autowired
    private StorageRoomMapper storageRoomMapper;

    @Override
    public int add(StorageRoom entity) {

        return 0;
    }

    @Override
    public int edit(StorageRoom entity) {
        return 0;
    }

    @Override
    public int remove(Integer id) {
        return 0;
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return 0;
    }

    @Override
    public List<StorageRoom> find() {
        return List.of();
    }

    /**
     * 分页查询
     * @param pageNum
     * @param pageSize
     * @param storageRoom
     * @return
     */
    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, StorageRoom storageRoom) {
        Page<StorageRoom> page=new Page<>(pageNum,pageSize);
        Page<StorageRoom> storageRoomPage = storageRoomMapper.select(page, storageRoom);

        long total = storageRoomPage.getTotal();
        long pages = storageRoomPage.getPages();
        List<StorageRoom> storageRooms = storageRoomPage.getRecords();


        Map<String, Object> map = new HashMap<>();
        map.put("total",total);
        map.put("pages",pages);
        map.put("list",storageRooms);

        return map;
    }

    @Override
    public StorageRoom findById(Integer id) {
        return null;
    }
}
